/**
 * Created by liguangsong on 16/8/4.
 */
import React from 'react'
import { Link, hashHistory } from 'react-router'
var getJson = require('../../assist/getJson');
import getTeamColorWithName from '../../assist/teamColor.js'


var PlayerInfoView = React.createClass( {
    getInitialState() {
        var url = 'commonplayerinfo?PlayerID=' + this.props.playerId;
        getJson(url, function(result) {
            this.setState({
                playerInfo: result['resultSets'][1]['rowSet'][0]
            })
        }.bind(this));

        return {
            playerInfo: []
        }
    },


    render() {
        var imgSrc = 'http://stats.nba.com/media/players/230x185/' + this.props.playerId + '.png';
        return (
            <div onClick={this.handleClick} className="teamPlayerInfo">
                <div className="teamPlayerHead" style={{ borderColor: this.props.color }}>
                    <img className="teamPlayerHead" src={imgSrc} />
                </div>
                <p className="teamInfoPlayerName">{this.props.playerName}</p>
                <pre className="locationAndNumber">{this.props.locationAndNumber}</pre>
                <div className="playerLine"></div>
                <p className="teamInfoPlayerInfo">Age: </p>
                <p className="teamInfoPlayerInfo" style={{left: '504px'}}>{this.props.age}</p>
                <p className="teamInfoPlayerInfo" style={{left: '570px'}}>Height: </p>
                <p className="teamInfoPlayerInfo" style={{left: '648px'}}>{this.props.height}</p>
                <p className="teamInfoPlayerInfo" style={{left: '710px'}}>Weight: </p>
                <p className="teamInfoPlayerInfo" style={{left: '794px'}}>{this.props.weight}</p>

                <p className="teamInfoPlayerData">{this.state.playerInfo[3]}</p>
                <p className="teamInfoPlayerDataName">PPT</p>
                <p className="teamInfoPlayerData" style={{ left: '550px' }}>{this.state.playerInfo[4]}</p>
                <p className="teamInfoPlayerDataName" style={{ left: '604px' }}>PPT</p>
                <p className="teamInfoPlayerData" style={{ left: '645px' }}>{this.state.playerInfo[5]}</p>
                <p className="teamInfoPlayerDataName" style={{ left: '698px' }}>AST</p>
                <p className="teamInfoPlayerData" style={{ left: '745px' }}>35</p>
                <p className="teamInfoPlayerDataName" style={{ left: '798px' }}>MIN</p>
                <p className="teamInfoPlayerData" style={{ left: '845px' }}>42</p>
                <p className="teamInfoPlayerDataName" style={{ left: '898px' }}>GP</p>
            </div>
        );
    },

    handleClick(event) {
        event.preventDefault();
        var link = '/Player/' + this.props.playerId + '/' + this.props.color + '/' + this.props.playerName;
        hashHistory.push(link);
    }
});

export default PlayerInfoView;